package br.ufmg.dcc.vod.remoteworkers.util;

import br.ufmg.dcc.vod.remoteworkers.Command;

public class RaceConditionCommand implements Command<Integer, Integer> {

	private static int GLOBAL_COUNTER = -1; //this variable is shared between all commands. it defines the race condition
	private int id = -1;
	
	@Override
	public final Integer getID() {
		return id;
	}
	
	@Override
	public Integer process() throws Exception {
		id = ++GLOBAL_COUNTER;
		return id;
	}
	
	public static void reset() {
		GLOBAL_COUNTER = -1;
	}
}
